//
//  ViewController.swift
//  XJUIKit
//
//  Created by lishengbing on 10/30/2017.
//  Copyright (c) 2017 lishengbing. All rights reserved.
//

import UIKit
import XJUIKit


class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationItem.title = "SLButton全新整合"
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "下一页", style: .plain, target: self, action: #selector(rightClick))

        setupUI1()
        setupUI2()
        setupUI3()
        setupUI4()
        
        setupUI5()
        setupUI6()
    }
    
    @objc fileprivate func rightClick() {
        let vc = NextVC()
        navigationController?.pushViewController(vc, animated: true)
    }
}

extension ViewController {
    
    /// 左边
    fileprivate func setupUI1() {
        let style = SLButtonStyle()
        style.buttonType = SLButtonType.leftIcon
        
        style.title = "斯特林中韩-左"
        style.icon = UIImage(named: "icon_Leisure")!
        /// 设置左边和右边间距，以icon在哪一边为基准
        style.leftIconMargin = 0
        /// 设置icon 和文字之间的水平间距
        style.horizontalMargin = 0
        
        let btn = SLButton(frame: CGRect.zero, style: style)
        btn.frame.origin = CGPoint(x: 5, y: 100)
        view.addSubview(btn)
        btn.backgroundColor = UIColor.orange
    }
    
    /// 右边
    fileprivate func setupUI2() {
        let style = SLButtonStyle()
        style.buttonType = SLButtonType.rightIcon
        /// 设置左边和右边间距，以icon在哪一边为基准
        style.rightIconMargin = 0
        /// 设置icon 和文字之间的水平间距
        style.horizontalMargin = 0
        
        style.title = "斯特林中韩-右"
        style.icon = UIImage(named: "icon_Leisure")!
        
        let btn = SLButton(frame: CGRect.zero, style: style)
        btn.frame.origin = CGPoint(x: 5 + 200, y: 100)
        view.addSubview(btn)
        btn.backgroundColor = UIColor.orange
    }
    
    /// 顶部
    fileprivate func setupUI3() {
        let style = SLButtonStyle()
        style.buttonType = SLButtonType.topIcon
        /// 设置上边和下边间距，以icon在哪一边为基准
        style.topIconMargin = 0
        /// 设置icon 和文字之间的上下间距
        style.verticalMargin = 0
        
        style.title = "斯特林中韩--上"
        style.icon = UIImage(named: "icon_Leisure")!
        
        let btn = SLButton(frame: CGRect.zero, style: style)
        btn.frame.origin = CGPoint(x: 5, y: 100 + 120)
        view.addSubview(btn)
        btn.backgroundColor = UIColor.orange
    }
    
    /// 底部
    fileprivate func setupUI4() {
        let style = SLButtonStyle()
        style.buttonType = SLButtonType.bottomIcon
        /// 设置上边和下边间距，以icon在哪一边为基准
        style.bottomIconMargin = 0
        /// 设置icon 和文字之间的上下间距
        style.verticalMargin = 0
        
        style.title = "斯特林中韩--下"
        style.icon = UIImage(named: "icon_Leisure")!
        
        let btn = SLButton(frame: CGRect.zero, style: style)
        btn.frame.origin = CGPoint(x: 5 + 200, y: 100 + 120)
        view.addSubview(btn)
        btn.backgroundColor = UIColor.orange
    }
    
    /// 只有文字
    fileprivate func setupUI5() {
        let style = SLButtonStyle()
        style.buttonType = SLButtonType.leftIcon
        
        
        style.title = "斯特林中韩"
        style.icon = UIImage()
        /// type == left , leftIconMargin左右间距
        style.leftIconMargin = 10
        style.btnHeight = 50
        
        let btn = SLButton(frame: CGRect.zero, style: style)
        btn.frame.origin = CGPoint(x: 5 , y: 100 + 120 + 120)
        view.addSubview(btn)
        btn.backgroundColor = UIColor.orange
    }
    
    /// 只有图片
    fileprivate func setupUI6() {
        let style = SLButtonStyle()
        style.buttonType = SLButtonType.topIcon
        style.title = ""
        style.icon = UIImage(named: "icon_Leisure")!
        /// type == top , topIconMargin上下间距
        style.topIconMargin = 10
        /// 设置水平方向的间距 
        style.horizontalMargin = 20
        
        let btn = SLButton(frame: CGRect.zero, style: style)
        btn.frame.origin = CGPoint(x: 5 + 200, y: 100 + 120 + 120)
        view.addSubview(btn)
        btn.backgroundColor = UIColor.orange
    }
}

